import java.util.Scanner;

public class Array_1_6_08 {
    public static void main(String[] args) {
        int n, na, nb;
        int[] a = new int[1010];
        int[] b = new int[1010];
        Scanner input = new Scanner(System.in);
        n = input.nextInt();
        na = input.nextInt();
        nb = input.nextInt();
        for (int i = 1; i <= na; i++) {
            a[i] = input.nextInt();
        }
        for (int i = 1; i <= nb; i++) {
            b[i] = input.nextInt();
        }
        for (int i = na + 1; i <= n; i++) {
            a[i] = i % na != 0 ? a[i % na] : a[na];
        }
        for (int i = nb + 1; i <= n; i++) {
            b[i] = i % nb != 0 ? b[i % nb] : b[nb];
        }

        int win_a = 0, win_b = 0;
        for (int i = 1; i <= n; i++) {
            //0->石头,2->剪刀,5->布
            switch (a[i]) {
                case 0:
                    if (b[i] == 2) win_a++;
                    if (b[i] == 5) win_b++;
                    break;
                case 2:
                    if (b[i] == 5) win_a++;
                    if (b[i] == 0) win_b++;
                    break;
                case 5:
                    if (b[i] == 0) win_a++;
                    if (b[i] == 2) win_b++;
                    break;
            }
        }
        if (win_a > win_b)
            System.out.println("A");
        if (win_b > win_a)
            System.out.println("B");
        if (win_a == win_b)
            System.out.println("draw");
    }
}